<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;

/**
 * Class GoodsCategory
 * 
 * @property int $id
 * @property string $category_name
 * @property int $pid
 * @property string|null $images
 * @property int|null $sort
 * @property Carbon|null $create_at
 * @property Carbon|null $update_at
 * @property Carbon|null $delete_at
 *
 * @package App\Models
 */
class GoodsCategory extends BaseModels
{
	protected $table = 'zh_goods_category';

	protected $casts = [
		'pid' => 'int',
		'sort' => 'int'
	];


	protected $fillable = [
		'category_name',
		'pid',
		'images',
		'sort',
		'create_at',
		'update_at',
		'delete_at'
	];


	protected $appends = [
	    'parents_name'
    ];


	public function getParentsNameAttribute()
    {
        return self::whereKey($this->pid)->value('category_name') ?: '--';
    }

}
